﻿@extends("admin.base.base")
@section("title")
<title>资讯列表</title>
@endsection
@section("content")
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 <span class="c-gray en">&gt;</span> 文章分类 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a class="btn btn-primary radius" data-title="添加分类" data-href="{{url('admin/classify/create')}}" onclick="Hui_admin_tab(this)" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加分类</a></span> <span class="r">共有数据：<strong></strong>{{$item->total()}}条</span> </div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="30">ID</th>
					<th width="120">文章分类名称</th>
					<th width="80">描述</th>
					<th width="40">所属分类</th>
					<th width="60">是否显示在导航栏</th>
					<th width="50">更新时间</th>
					<th width="60">操作</th>
				</tr>
			</thead>
			<tbody>
				@foreach($item as $items)
					<tr class="text-c">
						<td><input name="pid[]" type="checkbox" value=""></td>
						<td>{{$items->id}}</td>
						<td>{{$items->title}}</td>
						<td>{{$items->description}}</td>
						@if($items->two_level == 0)
							<td><span style="color: red">{{$items->title}}</span></td>
						@else

							<td>
								<span style="color: red">
									@foreach($two_level as $value)
										{{--@foreach($item as $v)--}}
											@if($value->two_level == $items->id)
												{{$items->title}}
											@endif
										{{--@endforeach--}}
									@endforeach
								</span>
							</td>

						@endif

						@if($items->is_display == 1)
							<td>是</td>
						@else
							<td>否</td>
						@endif
						<td>{{$items->updated_at}}</td>
						<td class="f-14 td-manage"> <a style="text-decoration:none" class="ml-5" onClick="article_edit('分类编辑','{{url('admin/classify/'.$items->id.'/edit')}}','{{$items->id}}')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration:none" class="ml-5" onClick="article_del(this,'{{$items->id}}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
					</tr>
				@endforeach
			</tbody>
		</table>
	</div>
</div>
@endsection
@section("js")
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{asset('lib/My97DatePicker/4.8/WdatePicker.js')}}"></script>
<script type="text/javascript" src="{{asset('lib/datatables/1.10.0/jquery.dataTables.min.js')}}"></script>
<script type="text/javascript" src="{{asset('lib/laypage/1.2/laypage.js')}}"></script>
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"pading":false,
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,6]}// 不参与排序的列
	]
});

/*分类-添加*/
function article_add(title,url,w,h){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*分类-编辑*/
function article_edit(title,url,id,w,h){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*分类-删除*/
function article_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
			type: 'POST',
			method:'DELETE',
			url: '{{url('admin/classify')}}'+'/'+id,
            data:{'_token':'{{csrf_token()}}'},
			dataType: 'json',
			success: function(data){
			    if (data.code == 0){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
				}else{
                    layer.msg(data.msg);
				}

			}
		});		
	});
}
</script>
@endsection